package com.ijustyce.denoise;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.ijustyce.denoise.DemoActivity.TransActivity;
import com.ijustyce.denoise.Utils.XToastUtils;
import com.xuexiang.xui.widget.alpha.XUIAlphaTextView;
import com.xuexiang.xui.widget.button.roundbutton.RoundButton;
import com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    MaterialEditText etPhoneNumber;
    MaterialEditText etVerifyCode;

    String UserName,PassWord;

    XUIAlphaTextView tv_other;
    XUIAlphaTextView tv_forget;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
//        startActivity(new Intent(this, TransActivity.class));
        initView();
    }

    public void onClick(View view) {
        etPhoneNumber = findViewById(R.id.et_phone_number);
        etVerifyCode = findViewById(R.id.et_verify_code);
        UserName = etPhoneNumber.getEditableText().toString().trim();
        PassWord = etVerifyCode.getEditableText().toString().trim();

        switch (view.getId()) {
            case R.id.btn_login:
                if (etPhoneNumber.validate()) {
                    if (etVerifyCode.validate()) {
                        XToastUtils.warning("登录成功");
                        Intent intent = new Intent(this, TransActivity.class);
                        startActivity(intent);
                        finish();
                    }
                }
//                else if( UserName.length() == 11)
//                {
//                    XToastUtils.warning("请输入正确的手机号");
//                }else{
//                    XToastUtils.warning("登录成功");
//                    Intent intent = new Intent(this, MenuActivity.class);
//                    startActivity(intent);
//                    finish();
//                }
                break;
            case R.id.tv_other_login:
                XToastUtils.warning("其他方式");
                break;
            case R.id.tv_forget_password:
                XToastUtils.warning("忘记密码");
                break;
        }
    }

    private void initView() {
        // 初始化控件
        tv_other = findViewById(R.id.tv_other_login);
        tv_forget = findViewById(R.id.tv_forget_password);

        tv_other.setOnClickListener(this);
        tv_forget.setOnClickListener(this);

    }

//    @Override
//    protected void attachBaseContext(Context newBase) {
//        //注入字体
//        super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
//    }
//
//    @Override
//    public void onClick(View v) {
//        Intent intent = new Intent();
//
//    }
}